package br.com.napoleao.controlfin.core.exception;

import java.util.ArrayList;
import java.util.List;

public class BusinessException extends Exception{
	
	private static final long serialVersionUID = 1L;
	
	private List<String> messages;
	public BusinessException() {
		messages = new ArrayList<String>();
	}
	
	public void addMessage(String msg){
		if(messages == null)
			messages = new ArrayList<String>();
		
		messages.add(msg);
	}
	
	public List<String> getMessages(){
		return messages;
	}
	
	public String getMessagesString(){
		
		String msgs = new String();
		
		for (String msg : messages) {
			msgs += msg + "\n";
		}
		
		return msgs;
	}
}
